<template>
	<view class="list bgfff">
		<view class="deliver-list bgfff" style="padding: 0;">
			<gui-empty v-if="noData">
				<template v-slot:img>
					<view class="gui-flex gui-rows gui-justify-content-center">
						<image class="nodata-img" src="../../static/image/no_curriculum_vitae.png" mode="widthFix">
						</image>
					</view>
				</template>
				<template v-slot:text>
					<text class="gui-text-small gui-block gui-text-center gui-margin-top gui-color-gray">暂无数据</text>
					<view class="zw" style="height: 200rpx;"></view>
				</template>
			</gui-empty>
			<view class="deliver-item gui-flex gui-align-items-start" v-for="(item, index) in dataList" :key="item.id">
				<view class="photo">
					<gui-image :src="item.userImg" :width="115" :height="115" borderRadius="60rpx"
						mode="aspectFill"></gui-image>
					<image class="sex_img" v-if="item.userSex == '0'" src="../../static/image/man.png" mode="widthFix">
					</image>
					<image class="sex_img" v-if="item.userSex == '1'" src="../../static/image/woman.png"
						mode="widthFix"></image>
				</view>
				<view class="info">
					<view class="f26 c333">
						{{ item.userName }}
					</view>
					<view class="f22 stress mt10">
						期望地点：<text
							v-if="item.comUserJobHuntList && item.comUserJobHuntList.length > 0">{{ item.comUserJobHuntList[0].addressName }}</text>
					</view>
					<view class="f22 c666 mt10">
						期望职位：<text
							v-if="item.comUserJobHuntList && item.comUserJobHuntList.length > 0">{{ item.comUserJobHuntList[0].postName }}</text>
					</view>
					<view class="sgin gui-flex">
						<view class="sgin-item">
							{{ item.userAge }}岁
						</view>
						<view class="sgin-item">
							{{ item.workTime }}
						</view>
						<view class="sgin-item" v-if="item.education">
							{{ item.education }}
						</view>
						<view class="sgin-item stress-warp" v-if="item.workStatus">
							{{ item.workStatus }}
						</view>
					</view>
					<view class="btn_pos">
						<button class="show_btn f20 cfff"
							@click="$u.to(`/pages/mine/curriculumVitae/curriculum-vitae?type=firm&id=${item.id}`)">查看</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import {
	ref,
	reactive,
	inject
} from 'vue'
const props = defineProps({
	queryOther: {
		type: Object,
		default: {
			industry: '', // 行业
			postName: '', //职业/岗位
			addressName: '', //城市
			workStatus: '', //工作性质
			workTime: '' //工作经验
		}
	}
})
import {
	onLoad
} from '@dcloudio/uni-app'
import {
	selectAllUserFollowList
} from '@/api/company.js';
const emit = defineEmits(['pageChange'])
const guipage = ref(null);
const $u = reactive(inject('$u'))
onLoad(() => {
	// 加载数据
	loadRc();
})

const dataList = ref([]);

const query = ref({
	pageNum: 1,
	pageSize: 10
})

const noData = ref(false);

const reload = () => {
	query.value.pageNum = 1;
	loadRc(true);
}

// 人才列表
const loadRc = (isReload) => {
	let queryParam = Object.assign(query.value, {})
	let otherQueryParam = Object.assign(props.queryOther, {})
	selectAllUserFollowList({
		...queryParam,
		...otherQueryParam
	}).then(res => {
		if (res.code == 200) {
			var resultArr = res.rows;
			let total = Math.ceil(res.total / queryParam.pageSize);
			if (queryParam.pageNum >= 2) {
				dataList.value = dataList.value.concat(resultArr);
				emit('pageChange', {
					value: 'stoploadmore'
				})
				// 假定第3页加载了全部数据，通知组件不再加载更多
				// 实际开发由接口返回值来决定
				if (queryParam.pageNum >= total) {
					emit('pageChange', {
						value: 'nomore'
					})
				}
			}
			// 第一页 有可能是第一次加载或者刷新
			else {
				dataList.value = [];
				dataList.value = resultArr;
				// 刷新
				if (isReload) {
					emit('pageChange', {
						value: 'endReload'
					})
				} else {
					emit('pageChange', {
						value: 'stoploadmore'
					})
				}
				(resultArr.length <= 0) ? noData.value = true : noData.value = false;
			}
			query.value.pageNum++;
		}
	})
}

// 抛出函数
defineExpose({
	loadRc,
	reload
})
</script>

<style lang="scss">
.search {
	padding: 28rpx 14rpx 24rpx 36rpx;

	.border {
		border: 1px solid #ccc;
	}

	.saveBtn {
		width: 97rpx;
		height: 53rpx;
		margin-left: 10rpx;
		font-size: 20rpx;
	}
}

.shai {
	padding: 20rpx 10rpx 14rpx 36rpx;

	.la {
		position: relative;
		top: -4rpx;
	}

	.label-item {
		padding: 6rpx 14rpx;
		background: #F5F5F5;
		border-radius: 14rpx;
		margin-left: 10rpx;
		margin-bottom: 10rpx;
	}

	.tool {
		position: relative;
		top: -4rpx;

		.tool-text {
			position: relative;
			padding: 6rpx 15rpx;

			&:last-child::before {
				content: "";
				position: absolute;
				left: 0;
				top: 50%;
				transform: translateY(-50%);
				width: 1px;
				height: 24rpx;
				background: #D50000;
			}
		}
	}
}

.list {
	padding: 0 36rpx;
	margin-top: 10rpx;
}

.sgin-item {
	max-width: 120rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	display: inline-block;
	vertical-align: middle;
	padding: 0 15rpx;
	box-sizing: border-box;
}
</style>